// 对象
// 1.直接通过let 对象名 = {对象属性}(直接给初始值)
let student = {
    name: "周星驰",
    age: 18,
    height: "180cm",
    weight: "80kg",
    test : function() {
        console.log("hello world");
    }
}

console.log(student.name)
console.log(student.age)
console.log(student.height)
console.log(student.weight)
student.test()
// 2.使用new Object创建对象（不给初始值，需要什么设置什么）
let student2 = new Object();
student2.name = "qinbo"
console.log(student2.name)
student2.age = 18
console.log(student2.age)
student2.test2 = function() {
    console.log("hello qinbo")
}
student2.test2()

// 3.使用构造函数创建对象（创建构造函数，想创建多个共性对象时，直接new构造函数并传参）
// 构造函数必须被this.引用，语法：function 函数名(参数){函数属性}
function People(name,height,weight) {
    this.name = name;
    this.height = height;
    this.weight = weight;
    this.test03 = function() {
        console.log(this.name + "是帅哥")
    }
}

let zhangSan = new People("张三","180","80kg")
console.log(zhangSan.name)
console.log(zhangSan.height)
console.log(zhangSan.weight)
zhangSan.test03()
let liSi = new People("李四","180","70kg")
console.log(liSi.name)
console.log(liSi.height)
console.log(liSi.weight)
liSi.test03()

// 4.创建类--使用constructor(参数),构造类参数，直接使用方法名(){}，创建方法
// 创建对象进行new即可
// 如果类中属性/方法使用static进行修饰，那么该属性/方法只属于类，其它对象无法调用
class People2 {
    constructor(name,height,weight) {
        this.name = name;
        this.height = height;
        this.weight = weight;
    }
    test04() {
        console.log(this.name + "哈哈哈哈")
    }
    static other = "other"
}

let wangWu = new People2("王五","180","60kg")
console.log(wangWu.name)
console.log(wangWu.height)
console.log(wangWu.weight)
// wangWu.other;调用报错
wangWu.test04()

let zhaoLiu = new People2("赵六","180","60kg")
console.log(wangWu.name)
console.log(wangWu.height)
console.log(wangWu.weight)
zhaoLiu.test04()

// 继承--类使用extends继承其它类，并使用super关键字调用其它类中的属性/方法并赋值（相当于this引用了父类）


